# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=atop
pkgver=2.7.1
pkgrel=1
pkgdesc="Resource-specific view of processes"
url="https://www.atoptool.nl/"
arch="all"
license="GPL-2.0-or-later"
makedepends="zlib-dev ncurses-dev linux-headers"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://www.atoptool.nl/download/atop-$pkgver.tar.gz
	atop-daily-bb.patch
	atop-include-macros.patch
	make-cron-background.patch
	atop.initd
"
options="suid !check"

prepare() {
	default_prepare

	sed -i -e '/^CFLAGS/s: = -O : += :' \
		-e '/DEFPATH/d' \
		-e '/^LDFLAGS/s: = : += :' Makefile

	cp "$srcdir"/atop.initd atop.init
	chmod a+rx atop.init
}

build() {
	make
}

package() {
	make DESTDIR="$pkgdir" \
		INIPATH=/etc/init.d \
		SCRPATH=/etc/periodic/daily \
		sysvinstall
	rm -fr "$pkgdir"/etc/cron.d
	mv "$pkgdir"/etc/periodic/daily/atop.daily \
		"$pkgdir"/etc/periodic/daily/atop
}

sha512sums="
f5013dbc25b86f07c9892555705bb3db2eeb949478f53e6e5545308b0c7c173c4c7a8ed0eae1f173e075210f81fceee09d7a9d90de76c4f011e38ad4a76b780b  atop-2.7.1.tar.gz
664225450074962aac0e13484c9b2feaf08620bbe1e0f9c5dc1b02f1ecd315224cd04df53134f2d107210fc9223a64d8885ae70d33d0663c2335fa6d46f6ddfd  atop-daily-bb.patch
f30c9e6051332af8c8cafcd881f89a0e2d2a8e1d84eee8ac0c8c6b58f3ae3431fcf9c40dea6d03e271f8969802de449d33b4323c13045bdb38a539732c81a8b6  atop-include-macros.patch
e563894eceadf63ff153714829218b8f78dd21a129b90817960bdb4452768f41ed884dc9967f94b979e42f04d6434fcbd423bcf1651976a5ad60c34b206ce7e9  make-cron-background.patch
172c9d367b936427ccbbbd1140c7808ec8ffe3194b3557ba024820dac8fa68c9919f7dc34d332e91283fde64d731db7bdbfee3c2d6caad3cd291e0f1c227cb03  atop.initd
"
